/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package kn.cstf2.implementation.Sql;

/**
 *
 * @author user1
 */
public class ImplementationSql {
    public static final String SELECCIONAR_ALLDATACLIENTFROMSTK;
    public static final String SELECCIONAR_IFOWNERFROMKNKEY;
    public static final String SELECCIONAR_STATUSFECHAARCHIVO;
    public static final String SELECCIONAR_IDKNKEY;
    public static final String SELECCIONAR_IDDOCUMENTS;
    public static final String SELECCIONAR_ALLRESTOFTRANSITION;
    public static final String UPDATE_STATUSCIELQ;
    public static final String UPDATE_STATUSCARRIER;
    public static final String GETDATE_STATUSTRANSITIONS;
    public static final String SELECCIONAR_JOINDOCUMENTTRANSITIONDATA;
    public static final String SELECCIONAR_COP;
    public static final String INSETAR_DATOSENCOP;
    public static final String UPDATE_STATUSCIELID;
    public static final String UPDATE_STATUS_DOCUMENT_COP;
    public static final String UPDATE_STATUS_DOCUMENT_CONTACTS;
    public static final String UPDATE_STATUS_DOCUMENT_REPORTING;
    public static final String UPDATE_STATUS_DOCUMENT_SOS;
    public static final String UPDATE_STATUS_DOCUMENT_CONDITIONS;
    public static final String UPDATE_STATUSDOCUMENT_CIELID;
    public static final String UPDATE_STATUS_DOCUMEWNT_CIELQ;
    public static final String UPDATE_STATUS_DOCUMENT_CARRIER;
    public static final String UPDATE_STATUS_DOCUMENT_WORKING;
    public static final String UPDATE_STATUS_DOCUMENT_SOP;
    public static final String UPDATE_STATUS_DOCUMENT_KPI;
    public static final String UPDATE_STATUS_DOCUMENT_BILLING;
    
    
     static {
        StringBuilder qryBuilder = new StringBuilder();
            qryBuilder.append("SELECT * "+
                " FROM t_clientes "+            
                " WHERE "+
                " knkey = ? ");
        SELECCIONAR_ALLDATACLIENTFROMSTK = qryBuilder.toString();
        
        qryBuilder = new StringBuilder();
        qryBuilder.append(" UPDATE t_transitions SET cielid = ? WHERE id = ? returning cieliddate ");
        UPDATE_STATUSCIELID = qryBuilder.toString();
        
        
        qryBuilder = new StringBuilder();
        qryBuilder.append("SELECT ifowner "+
            "FROM t_assign "+            
            " WHERE "+
            " knkey = ? ");
        SELECCIONAR_IFOWNERFROMKNKEY = qryBuilder.toString();
        
        
        qryBuilder = new StringBuilder();
        qryBuilder.append(" SELECT vobo, uploaded, completiondate "+
            " FROM joindocumenttransition "+            
            " WHERE idtransition = ? and iddocument = ? ");
        SELECCIONAR_STATUSFECHAARCHIVO = qryBuilder.toString();
        
        
        qryBuilder = new StringBuilder();
        qryBuilder.append("SELECT id FROM t_transitions WHERE  knkey = ? ");
        SELECCIONAR_IDKNKEY = qryBuilder.toString();
        
        
        qryBuilder = new StringBuilder();
        qryBuilder.append(" SELECT id FROM t_documents WHERE  name = ? ");
        SELECCIONAR_IDDOCUMENTS = qryBuilder.toString();
        
        
        qryBuilder = new StringBuilder();
        qryBuilder.append(" SELECT * FROM t_transitions WHERE id = ? ");
        SELECCIONAR_ALLRESTOFTRANSITION = qryBuilder.toString();
        
        
        qryBuilder = new StringBuilder();
        qryBuilder.append(" UPDATE t_transitions SET cielqmodule = ? WHERE id = ? returning cielqmoduledate ");
        UPDATE_STATUSCIELQ = qryBuilder.toString();
        
        
        qryBuilder = new StringBuilder();
        qryBuilder.append(" UPDATE t_transitions SET carriercc = ? WHERE id = ? returning carrierccdate ");
        UPDATE_STATUSCARRIER = qryBuilder.toString();
        
        
        qryBuilder = new StringBuilder();
        qryBuilder.append(" SELECT * FROM t_transitions WHERE id = ? ");
        GETDATE_STATUSTRANSITIONS = qryBuilder.toString();
        
        
        qryBuilder = new StringBuilder();
        qryBuilder.append("SELECT j.vobo, j.uploaded, j.completiondate FROM t_documents d "
                + "INNER JOIN joindocumenttransition j on d.id=j.iddocument "
                + "WHERE j.idtransition = ? ");
        SELECCIONAR_JOINDOCUMENTTRANSITIONDATA = qryBuilder.toString();
        
        
        qryBuilder = new StringBuilder();
        qryBuilder.append(" SELECT * FROM t_cop WHERE idtransitioncop = ? AND export = ? ");
        SELECCIONAR_COP = qryBuilder.toString();
        
        
        qryBuilder = new StringBuilder();
        qryBuilder.append(" INSERT INTO t_cop (export, fcl, lcl, perishables, brokerage, intermodal, insurance, "
                + " oceanfreight, blueancorline, seatransport, exportcustoms, inbondexp, importcustoms, inbondim, preallmotor, precombined, "
                + " onallmotor, oncombined, attachedfiles, pickuptosiling, customsclearance, "
                + " maincarriage, arrivaltocustoms, arrivaltodelivery, escortkn, escortclient, idtransitioncop )"
                + " VALUES ( ?, false, false,  false,  false,  false,  false,  false,  false,  false,  false, "
                + " false,  false,  false,  false,  false,  false,  false,  0,  false,  false,  false,  false, "
                + " false,  false,  false,  ? ) ");
        INSETAR_DATOSENCOP = qryBuilder.toString();
        
        qryBuilder = new StringBuilder();
        qryBuilder.append(" UPDATE t_transitions SET cop= ?, copdate=?, copfecha = ? WHERE id= ? returning copdate; ");
        UPDATE_STATUS_DOCUMENT_COP = qryBuilder.toString();
        
        qryBuilder = new StringBuilder();
        qryBuilder.append(" UPDATE t_transitions SET contacts= ?, contactsdate=?, contactsfecha = ? WHERE id= ? returning contactsdate; ");
        UPDATE_STATUS_DOCUMENT_CONTACTS = qryBuilder.toString();
        
        qryBuilder = new StringBuilder();
        qryBuilder.append(" UPDATE t_transitions SET reporting= ?, reportingdate=?, reportingfecha = ? WHERE id= ? returning reportingdate; ");
        UPDATE_STATUS_DOCUMENT_REPORTING = qryBuilder.toString();
        
        qryBuilder = new StringBuilder();
        qryBuilder.append(" UPDATE t_transitions SET scopeofservice= ?, scopeofservicedate=?, sosfecha = ? WHERE id= ? returning scopeofservicedate; ");
        UPDATE_STATUS_DOCUMENT_SOS = qryBuilder.toString();
        
        qryBuilder = new StringBuilder();
        qryBuilder.append(" UPDATE t_transitions SET condition= ?, conditionsdate=?, conditionsfecha = ? WHERE id= ? returning conditionsdate; ");
        UPDATE_STATUS_DOCUMENT_CONDITIONS = qryBuilder.toString();
        
        qryBuilder = new StringBuilder();
        qryBuilder.append(" UPDATE t_transitions SET cielid= ?, cieliddate=?, cielidfecha = ? WHERE id= ? returning cieliddate; ");
        UPDATE_STATUSDOCUMENT_CIELID = qryBuilder.toString();
        
        qryBuilder = new StringBuilder();
        qryBuilder.append(" UPDATE t_transitions SET cielqmodule = ?, cielqmoduledate =?, cielqmfecha = ? WHERE id = ? returning cielqmoduledate ");
        UPDATE_STATUS_DOCUMEWNT_CIELQ = qryBuilder.toString();
        
        qryBuilder = new StringBuilder();
        qryBuilder.append(" UPDATE t_transitions SET carriercc = ?, carrierccdate=?, carrierfecha = ? WHERE id = ? returning carrierccdate ");
        UPDATE_STATUS_DOCUMENT_CARRIER = qryBuilder.toString();
        
        qryBuilder = new StringBuilder();
        qryBuilder.append(" UPDATE t_transitions SET workingst = ?, workingstdate=?, workingfecha = ? WHERE id = ? returning workingstdate ");
        UPDATE_STATUS_DOCUMENT_WORKING = qryBuilder.toString();
        
        qryBuilder = new StringBuilder();
        qryBuilder.append(" UPDATE t_transitions SET sop = ?, sopdate=?, sopfecha = ? WHERE id = ? returning sopdate ");
        UPDATE_STATUS_DOCUMENT_SOP = qryBuilder.toString();
        
        qryBuilder = new StringBuilder();
        qryBuilder.append(" UPDATE t_transitions SET kpi = ?, kpidate=?, kpifecha = ?  WHERE id = ? returning kpidate ");
        UPDATE_STATUS_DOCUMENT_KPI = qryBuilder.toString();
        
        qryBuilder = new StringBuilder();
        qryBuilder.append(" UPDATE t_transitions SET billing = ?, billingdate=?, billingfecha = ? WHERE id = ? returning billingdate ");
        UPDATE_STATUS_DOCUMENT_BILLING = qryBuilder.toString();
     }
}
